<template>
  <div class="daily-item">
    <div class="daily-item-content">
      <div class="daily-item--title text-ellipsis">
        {{pname}}
      </div>
      <div class="daily-item--detail">
        <span>{{name}}</span>
        <span>折扣：{{discount}}</span>
        <span>消耗：{{consume}}</span>
        <span>提点：{{proportion}}%</span>
        <span>提成：{{commission}}</span>
      </div>
      <div class="daily-item--bottom text-ellipsis">
        {{payTimeStr}}
      </div>
    </div>
    <div class="daily-item-action">
      <yd-checkbox v-model="currentChecked" shape="circle"></yd-checkbox>
    </div>
  </div>
</template>

<script>
import _ from "lodash";
export default {
  props: {
    value: {},
    id: {},
    pname: {
      default: () => "--",
    },
    name: {
      default: () => "--",
    },
    discount: {
      default: () => "--",
    },
    consume: {
      default: () => "--",
    },
    proportion: {
      default: () => "--",
    },
    commission: {
      default: () => "--",
    },
    payTime: {
      default: () => null,
    },
  },
  computed: {
    currentChecked: {
      get() {
        let r = this.value.findIndex(item => {
          return item === this.id;
        });
        return r >= 0;
      },
      set(val) {
        let _val = this.value.concat(this.id);
        if (val) {
          this.$emit("input", _.uniq(_val));
        } else {
          _.remove(_val, item => {
            return item === this.id;
          });
          _log(_val);
          this.$emit("input", _val);
        }
      },
    },
    payTimeStr() {
      if (!this.payTime) {
        return "--";
      } else {
        return new Date().$formatStr("yyyy-MM-dd");
      }
    },
  },
  methods: {},
  created() {},
};
</script>

<style>

</style>
